<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/6/28
  Time: 16:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html >
    <head>
        <title>Title</title>
        <!--引入layui样式文件-->
        <link rel="stylesheet" href="layui/css/layui.css">
    </head>
    <body>

    <div class="layui-form-item">
        <label class="layui-form-label">预定号</label>
        <div class="layui-input-block">
            <input type="text" id="reservationNum"   class="layui-input"  disabled="disabled"
                   style="width: 200px;">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">房间号码</label>
        <div class="layui-input-block">
            <input type="text" id="roomNum"   class="layui-input"
                   style="width: 200px;">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">房间类型</label>
        <div class="layui-input-block">
            <input type="text" id="type"   class="layui-input"
                   style="width: 200px;" disabled="disabled">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">房间价格</label>
        <div class="layui-input-block">
            <input type="text" id="price"   class="layui-input"
                   style="width: 200px;" >
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">折后价</label>
        <div class="layui-input-block">
            <input type="text" id="discountPrice"   class="layui-input"
                   style="width: 200px;">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">押金</label>
        <div class="layui-input-block">
            <input type="text" id="deposit"   class="layui-input"
                   style="width: 200px;">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-block">
            <input type="text" id="userName"   class="layui-input"
                   style="width: 200px;" >
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">电话</label>
        <div class="layui-input-block">
            <input type="text" id="telephone"   class="layui-input"
                   style="width: 200px;" >
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">到达时间</label>
        <div class="layui-input-block">
            <input type="text" id="arrivalTime"   class="layui-input"
                   style="width: 200px;" layui-inline>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">离开时间</label>
        <div class="layui-input-block">
            <input type="text" id="departTime"   class="layui-input"
                   style="width: 200px;" layui-inline>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">用户数量</label>
        <div class="layui-input-block">
            <input type="text" id="userCount"   class="layui-input"
                   style="width: 200px;" >
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">操作人员</label>
        <div class="layui-input-block">
            <input type="text" id="operatorNum"   class="layui-input"
                   style="width: 200px;" >
        </div>
    </div>

    <button class="layui-btn layui-btn-normal"
            style="margin-left: 200px;" onclick="save()">保存</button>
    </body>
<script src="layui/layui.js"></script>

    <script>
        layui.use('laydate', function(){
            var laydate = layui.laydate;

            //执行一个laydate实例
            laydate.render({
                elem: '#arrivalTime' //指定元素
            });
        });
    </script>
    <script>
        layui.use('laydate', function(){
            var laydate = layui.laydate;

            //执行一个laydate实例
            laydate.render({
                elem: '#departTime' //指定元素
            });
        });
    </script>

<script>
    var $;
    layui.use(['jquery'],function() {
        $ = layui.jquery;
        $("#roomNum").blur(function () {
            $.ajax({
                url: "getRoomByRoomNum",
                type: "post",
                data: {roomNum: $("#roomNum").val()},
                dataType: "json",
                success: function (param) {
                    if (param.code == 0) {
                        $("#type").val(param.data.type);
                        $("#price").val(param.data.roomPrice);
                        $("#discountPrice").val(param.data.discountPrice);
                    }
                },
                error: function () {
                }

            })

        });
    });

    function save(){
        if($("#roomNum").val()==''||$("#roomNum").val()==null){
            alert("房间号不能为空");
            return;
        }
        if($("#deposit").val()==''||$("#deposit").val()==null){
            alert("押金楼层号不能为空");
            return;
        }
        if($("#userName").val()==''||$("#userName").val()==null){
            alert("用户名不能为空");
            return;
        }
        if($("#telephone").val()==''||$("#telephone").val()==null){
            alert("电话不能为空");
            return;
        }
        if($("#arrivalTime").val()==''||$("#arrivalTime").val()==null){
            alert("到达时间不能为空");
            return;
        }
        if($("#departTime").val()==''||$("#departTime").val()==null){
            alert("离开时间不能为空");
            return;
        }
        if($("#userCount").val()==''||$("#userCount").val()==null){
            alert("用户数量不能为空");
            return;
        }
        if($("#operatorNum").val()==''||$("#operatorNum").val()==null) {
            alert("操作人员不能为空");
            return;
        }

        var index = parent.layer.getFrameIndex(window.name);
        window.parent.addPreplot(1,$("#roomNum").val(),$("#type").val(),$("#price").val(),$("#discountPrice").val(),$("#deposit").val(),$("#userName").val(),$("#telephone").val(),$("#arrivalTime").val(),$("#departTime").val(),$("#userCount").val(),$("#operatorNum").val());
        parent.layer.close(index);
    }

</script>
</html>